<?php
namespace addons\xykeep\job;

use think\queue\Job;
use app\api\model\xykeep\course\Order as courseOrderModel;
class Order
{
    /**
     * 订单自动关闭
     */
    public function autoClose(Job $job, $data)
    {

        $orderModel = new CourseOrderModel();
        $order = $orderModel->where(['id' => $data['order']['id']])->find();
        if ($order['status'] == 0) {
            $order->status = -1;
            $order->save();

            $params = ['order' => $order, 'type' => 'course'];
            \think\Hook::listen('xykeep_order_back_after', $params);
        }
        $job->delete();
    }
}